<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h2>函数默认值</h2>
</body>
<script>
    //ES6的默认值写法
    function Person(name='无名',age=0,address='北京') {
        console.log(name)
        console.log(age)
        console.log(address)
    }

    //ES6以前的写法
    function Person2(name,age,address) {
        name=name || '无名'
        age=age || '无名'
        address=address || '无名'
    }

    Person('张三',18)

</script>
</html>